<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="PesquisaClienteLoteForm">
    

				<rich:panel id="painelAddLote">
				<f:facet name="header">Lote(s)</f:facet>
				
				<div class="dialog">
					<table>
						<tr>
							<td>Codigo</td>
						</tr>
						
						<tr>
			
							<td>
								<h:inputText value="#{VendaBean.codigoLote}" size="10" >
								</h:inputText>
							</td>

							<td>
								<a:commandButton id="addLote" value="Adicionar Lote"
									action="#{VendaBean.addLote}"
									rendered="#{conversation.longRunning}" reRender="painelListaLotes,painelAddLote" />
									
							</td>
						</tr>
						<tr>
							<td><h:messages /></td>
						</tr>
						

					</table>
				</div>

				<div style="clear: both" />

			</rich:panel>


			<rich:panel id="painelListaLotes">
				<f:facet name="header">Lotes - Selecionadas</f:facet>


				<div class="dialog"><h:outputText
					value="Não existe registro."
					rendered="#{empty VendaBean.lotes}" />
					
					<rich:dataTable id="lotesSelecionadosList" value="#{VendaBean.lotes}"
					var="_lotesSelecionado" rendered="#{not empty VendaBean.lotes}" styleClass="center-text" >
					
					<h:column>
						<f:facet name="header">codigoLote</f:facet>
                    	#{_lotesSelecionado.codigoLote}
					</h:column>
					
					<h:column>
						<f:facet name="header">quadra</f:facet>
                    	#{_lotesSelecionado.quadra.codigo}
					</h:column>
					
					<h:column>
						<f:facet name="header">grupo</f:facet>
                    	#{_lotesSelecionado.grupoLote.name}
					</h:column>
					
					<rich:column>
						<f:facet name="header">valor</f:facet>
                    	#{_lotesSelecionado.valor}
					</rich:column>
					
	                <h:column>
	                    <f:facet name="header">Remove</f:facet>
	                    <a:commandLink id="linkRemoveLote"
	                         value="Remove"
	                         action="#{VendaBean.removeLote(_lotesSelecionado)}" reRender="painelListaLotes"/>
	                </h:column>
					
				</rich:dataTable></div>
				
				<s:div  rendered="#{not empty VendaBean.lotes}">
					<br/>
					<h:outputText value="Valor da venda: R$ #{VendaBean.valorTotalLotes()}" />
				</s:div>
				
				<div style="clear: both" />

			</rich:panel>
        
        <div class="actionButtons">
    		<s:button id="btLote" value="Cliente" view="/vendaCliente.xhtml" rendered="#{conversation.longRunning}" propagation="join" />
    		<s:button id="btFinancimentoCaixa" value="Financeiro" view="/vendaFinanceiro.xhtml" rendered="#{conversation.longRunning}" propagation="join" />
        
        </div>
        
        

    </h:form>

</ui:define>

</ui:composition>
